package com.yunhe.authority.repository.wechat;

import com.yunhe.authority.domain.wechat.WechatLoginRecord;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhengbo
 * @date 2021/2/24 10:20
 */
@Repository
public interface WechatLoginRecordRepository extends Neo4jRepository<WechatLoginRecord, Long> {

    @Query(" match(w:WechatLoginRecord) where w.openid={openid} return w ")
    List<WechatLoginRecord> findByOpenid(@Param("openid") String openid);

    @Query(" match(w:WechatLoginRecord) where w.unionid={unionid} return w ")
    List<WechatLoginRecord> findByUnionid(@Param("unionid") String unionid);

    @Query(" match(w:WechatLoginRecord) where w.userPhone={phone} return w ")
    WechatLoginRecord findByPhone(@Param("phone") String phone);

    @Query(" match(w:WechatLoginRecord) where w.userId={userId} and w.openid={openid} return w ")
    WechatLoginRecord findByUserIdAndOpenid(@Param("userId") Long userId, @Param("openid") String openid);

}
